/**
 * NoServicePanel
 * @Author ace.ch
 * @Date 2018/3/29 19:13
 */
class NoServicePanel extends BasePanel {

    scroller: eui.Scroller;
    container: eui.Group;
    btn_weixin: eui.Button;

    constructor() {
        super();

        this.skinName = 'NoServicePanelSkin';
    }

    childrenCreated() {
        super.childrenCreated();

        this.btn_weixin.visible = false;

        this.update();

        this.btn_weixin.addEventListener(egret.TouchEvent.TOUCH_TAP, this.clickHandler, this);
    }

    private clickHandler(e: egret.TouchEvent) {
        switch (e.currentTarget) {
            case this.btn_weixin:
                Weixin.closeWindow();
                break;
        }
    }

    update() {
        this.scroller.stopAnimation();

        this.container.removeChildren();
        this.container.scrollV = 0;
        this.container.validateNow();

        let data: any;
        for (let i: number = 0; i < GameConfig.notice_noservice.length; i++) {
            data = GameConfig.notice_noservice[i];

            let arr: Array<any> = [];
            let style: any = {};
            style.textAlign = data.align ? data.align : "left";
            style.fontFamily = data.font ? data.font : "微软雅黑";
            style.textColor = data.color ? data.color : 0x6B5280;
            style.bold = data.bold ? data.bold : false;
            style.size = data.size ? data.size : 24;
            style.lineSpacing = data.lineSpacing ? data.lineSpacing : 5;

            arr.push({
                text: data["txt"],
                style: style
            });

            let label: eui.Label = new eui.Label();
            label.textAlign = style.textAlign;
            label.lineSpacing = style.lineSpacing;
            label.multiline = true;
            label.wordWrap = true;
            label.textFlow = arr;
            this.container.addChild(label);
        }
    }
}